# -*- coding:utf-8
"""
作者: Jia
日期: 2022年04月18日
描述: https://leetcode-cn.com/problems/subtract-the-product-and-sum-of-digits-of-an-integer/
"""


class Solution:
    def subtractProductAndSum(self, n: int) -> int:
        product_val = 1
        sum_val = 0
        while n > 0:
            val = n % 10
            product_val *= val
            sum_val += val
            n = n // 10
        return product_val - sum_val


s = Solution()
s.subtractProductAndSum(234)
